﻿Imports System.Text
Namespace DataMaster
    Public Class clsMSTSTORERow
        Inherits ADODBU.RowClass
        Private mVar_STRCOD As System.Int32
        Private mVar_STORE As System.String
        Private mVar_STRDESC As System.String
        Private mVar_STRTYPE As System.Int32
        Private mVar_STRADDR As System.String
        Private mVar_STRCITY As System.String
        Private mVar_STRDEPT As System.String
        Private mVar_STRSITE As System.Int32
        Private mVar_STRNOTE As System.String
        Private mVar_STRDCRE As System.DateTime
        Private mVar_STRDMAJ As System.DateTime
        Private mVar_STRUTIL As System.String
        Private mVar_STRPROG As System.String
        Private mVar_DirtySTRCOD As Boolean = False
        Private mVar_DirtySTORE As Boolean = False
        Private mVar_DirtySTRDESC As Boolean = False
        Private mVar_DirtySTRTYPE As Boolean = False
        Private mVar_DirtySTRADDR As Boolean = False
        Private mVar_DirtySTRCITY As Boolean = False
        Private mVar_DirtySTRDEPT As Boolean = False
        Private mVar_DirtySTRSITE As Boolean = False
        Private mVar_DirtySTRNOTE As Boolean = False
        Private mVar_DirtySTRDCRE As Boolean = False
        Private mVar_DirtySTRDMAJ As Boolean = False
        Private mVar_DirtySTRUTIL As Boolean = False
        Private mVar_DirtySTRPROG As Boolean = False
        Private mIsOnInit As Boolean
        Public DataSource As ADODBU.Recordset
        Public RowOrigin As clsMSTSTORERow
        ''[------------------------------------------------------------------------]'
        Public Sub New()
            RowOrigin = New clsMSTSTORERow(True)
        End Sub
        ''[------------------------------------------------------------------------]'
        Friend Sub New(lCut As Boolean)
            '--- untuk memutus loop reference 
        End Sub
        ''[------------------------------------------------------------------------]'
        ''' <summary>
        ''' create new this class from inherited of this class or its self
        ''' </summary>
        ''' <param name="recdataRow"></param>
        ''' <remarks></remarks>
        Public Sub New(ByVal recdataRow As ADODBU.RowClass)
            RowOrigin = New clsMSTSTORERow(True)
            Me.JoinValue(recdataRow)
        End Sub
        ''[------------------------------------------------------------------------]'
        Public Sub New(recData As ADODBU.Recordset)
            RowOrigin = New clsMSTSTORERow(True)
            DataSource = recData
            Try
                InitVar(recData.GetCurrentDataRow)
            Catch
            End Try
        End Sub

        ''[------------------------------------------------------------------------]'
        Public Sub New(recdataRow As DataRow)
            RowOrigin = New clsMSTSTORERow(True)
            InitVar(recdataRow)
        End Sub

#Region "Initialize vars "
        ''[------------------------------------------------------------------------]'
        Private Sub InitVar(Fields As DataRow)
            Try
                mVar_STRCOD = Fields("STRCOD")
                RowOrigin.STRCOD = mVar_STRCOD
            Catch e As Exception
            End Try
            Try
                mVar_STORE = Fields("STORE")
                RowOrigin.STORE = mVar_STORE
            Catch e As Exception
            End Try
            Try
                mVar_STRDESC = Fields("STRDESC")
                RowOrigin.STRDESC = mVar_STRDESC
            Catch e As Exception
            End Try
            Try
                mVar_STRTYPE = Fields("STRTYPE")
                RowOrigin.STRTYPE = mVar_STRTYPE
            Catch e As Exception
            End Try
            Try
                mVar_STRADDR = Fields("STRADDR")
                RowOrigin.STRADDR = mVar_STRADDR
            Catch e As Exception
            End Try
            Try
                mVar_STRCITY = Fields("STRCITY")
                RowOrigin.STRCITY = mVar_STRCITY
            Catch e As Exception
            End Try
            Try
                mVar_STRDEPT = Fields("STRDEPT")
                RowOrigin.STRDEPT = mVar_STRDEPT
            Catch e As Exception
            End Try
            Try
                mVar_STRSITE = Fields("STRSITE")
                RowOrigin.STRSITE = mVar_STRSITE
            Catch e As Exception
            End Try
            Try
                mVar_STRNOTE = Fields("STRNOTE")
                RowOrigin.STRNOTE = mVar_STRNOTE
            Catch e As Exception
            End Try
            Try
                mVar_STRDCRE = Fields("STRDCRE")
                RowOrigin.STRDCRE = mVar_STRDCRE
            Catch e As Exception
            End Try
            Try
                mVar_STRDMAJ = Fields("STRDMAJ")
                RowOrigin.STRDMAJ = mVar_STRDMAJ
            Catch e As Exception
            End Try
            Try
                mVar_STRUTIL = Fields("STRUTIL")
                RowOrigin.STRUTIL = mVar_STRUTIL
            Catch e As Exception
            End Try
            Try
                mVar_STRPROG = Fields("STRPROG")
                RowOrigin.STRPROG = mVar_STRPROG
            Catch e As Exception
            End Try
        End Sub


#End Region
        ''[------------------------------------------------------------------------]'
#Region "Properties"
        Public Property STRCOD As System.Int32
            Get
                Return mVar_STRCOD
            End Get
            Set(ByVal Value As System.Int32)
                mVar_STRCOD = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRCOD"))
                If Not mIsOnInit Then
                    mVar_DirtySTRCOD = True
                End If
            End Set
        End Property
        Public Property STORE As System.String
            Get
                Return mVar_STORE
            End Get
            Set(ByVal Value As System.String)
                mVar_STORE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STORE"))
                If Not mIsOnInit Then
                    mVar_DirtySTORE = True
                End If
            End Set
        End Property
        Public Property STRDESC As System.String
            Get
                Return mVar_STRDESC
            End Get
            Set(ByVal Value As System.String)
                mVar_STRDESC = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRDESC"))
                If Not mIsOnInit Then
                    mVar_DirtySTRDESC = True
                End If
            End Set
        End Property
        Public Property STRTYPE As System.Int32
            Get
                Return mVar_STRTYPE
            End Get
            Set(ByVal Value As System.Int32)
                mVar_STRTYPE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRTYPE"))
                If Not mIsOnInit Then
                    mVar_DirtySTRTYPE = True
                End If
            End Set
        End Property
        Public Property STRADDR As System.String
            Get
                Return mVar_STRADDR
            End Get
            Set(ByVal Value As System.String)
                mVar_STRADDR = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRADDR"))
                If Not mIsOnInit Then
                    mVar_DirtySTRADDR = True
                End If
            End Set
        End Property
        Public Property STRCITY As System.String
            Get
                Return mVar_STRCITY
            End Get
            Set(ByVal Value As System.String)
                mVar_STRCITY = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRCITY"))
                If Not mIsOnInit Then
                    mVar_DirtySTRCITY = True
                End If
            End Set
        End Property
        Public Property STRDEPT As System.String
            Get
                Return mVar_STRDEPT
            End Get
            Set(ByVal Value As System.String)
                mVar_STRDEPT = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRDEPT"))
                If Not mIsOnInit Then
                    mVar_DirtySTRDEPT = True
                End If
            End Set
        End Property
        Public Property STRSITE As System.Int32
            Get
                Return mVar_STRSITE
            End Get
            Set(ByVal Value As System.Int32)
                mVar_STRSITE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRSITE"))
                If Not mIsOnInit Then
                    mVar_DirtySTRSITE = True
                End If
            End Set
        End Property
        Public Property STRNOTE As System.String
            Get
                Return mVar_STRNOTE
            End Get
            Set(ByVal Value As System.String)
                mVar_STRNOTE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRNOTE"))
                If Not mIsOnInit Then
                    mVar_DirtySTRNOTE = True
                End If
            End Set
        End Property
        Public Property STRDCRE As System.DateTime
            Get
                Return mVar_STRDCRE
            End Get
            Set(ByVal Value As System.DateTime)
                mVar_STRDCRE = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRDCRE"))
                If Not mIsOnInit Then
                    mVar_DirtySTRDCRE = True
                End If
            End Set
        End Property
        Public Property STRDMAJ As System.DateTime
            Get
                Return mVar_STRDMAJ
            End Get
            Set(ByVal Value As System.DateTime)
                mVar_STRDMAJ = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRDMAJ"))
                If Not mIsOnInit Then
                    mVar_DirtySTRDMAJ = True
                End If
            End Set
        End Property
        Public Property STRUTIL As System.String
            Get
                Return mVar_STRUTIL
            End Get
            Set(ByVal Value As System.String)
                mVar_STRUTIL = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRUTIL"))
                If Not mIsOnInit Then
                    mVar_DirtySTRUTIL = True
                End If
            End Set
        End Property
        Public Property STRPROG As System.String
            Get
                Return mVar_STRPROG
            End Get
            Set(ByVal Value As System.String)
                mVar_STRPROG = Value
                Me.OnPropertyChanged(New System.ComponentModel.PropertyChangedEventArgs("STRPROG"))
                If Not mIsOnInit Then
                    mVar_DirtySTRPROG = True
                End If
            End Set
        End Property
        Public ReadOnly Property STRCODIsDirty As Boolean
            Get
                Return mVar_DirtySTRCOD
            End Get
        End Property
        Public ReadOnly Property STOREIsDirty As Boolean
            Get
                Return mVar_DirtySTORE
            End Get
        End Property
        Public ReadOnly Property STRDESCIsDirty As Boolean
            Get
                Return mVar_DirtySTRDESC
            End Get
        End Property
        Public ReadOnly Property STRTYPEIsDirty As Boolean
            Get
                Return mVar_DirtySTRTYPE
            End Get
        End Property
        Public ReadOnly Property STRADDRIsDirty As Boolean
            Get
                Return mVar_DirtySTRADDR
            End Get
        End Property
        Public ReadOnly Property STRCITYIsDirty As Boolean
            Get
                Return mVar_DirtySTRCITY
            End Get
        End Property
        Public ReadOnly Property STRDEPTIsDirty As Boolean
            Get
                Return mVar_DirtySTRDEPT
            End Get
        End Property
        Public ReadOnly Property STRSITEIsDirty As Boolean
            Get
                Return mVar_DirtySTRSITE
            End Get
        End Property
        Public ReadOnly Property STRNOTEIsDirty As Boolean
            Get
                Return mVar_DirtySTRNOTE
            End Get
        End Property
        Public ReadOnly Property STRDCREIsDirty As Boolean
            Get
                Return mVar_DirtySTRDCRE
            End Get
        End Property
        Public ReadOnly Property STRDMAJIsDirty As Boolean
            Get
                Return mVar_DirtySTRDMAJ
            End Get
        End Property
        Public ReadOnly Property STRUTILIsDirty As Boolean
            Get
                Return mVar_DirtySTRUTIL
            End Get
        End Property
        Public ReadOnly Property STRPROGIsDirty As Boolean
            Get
                Return mVar_DirtySTRPROG
            End Get
        End Property
#End Region
        ''[------------------------------------------------------------------------]'
        Public Function SaveToDataSource() As String
            Dim msgErr As String
            msgErr = ""
            If mVar_DirtySTRCOD Then
                Try
                    DataSource.Fields("STRCOD") = mVar_STRCOD
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTORE Then
                Try
                    DataSource.Fields("STORE") = mVar_STORE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRDESC Then
                Try
                    DataSource.Fields("STRDESC") = mVar_STRDESC
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRTYPE Then
                Try
                    DataSource.Fields("STRTYPE") = mVar_STRTYPE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRADDR Then
                Try
                    DataSource.Fields("STRADDR") = mVar_STRADDR
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRCITY Then
                Try
                    DataSource.Fields("STRCITY") = mVar_STRCITY
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRDEPT Then
                Try
                    DataSource.Fields("STRDEPT") = mVar_STRDEPT
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRSITE Then
                Try
                    DataSource.Fields("STRSITE") = mVar_STRSITE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRNOTE Then
                Try
                    DataSource.Fields("STRNOTE") = mVar_STRNOTE
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRDCRE Then
                Try
                    DataSource.Fields("STRDCRE") = Format(mVar_STRDCRE, DataSource.DbConn.DateFormat)
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRDMAJ Then
                Try
                    DataSource.Fields("STRDMAJ") = Format(mVar_STRDMAJ, DataSource.DbConn.DateFormat)
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRUTIL Then
                Try
                    DataSource.Fields("STRUTIL") = mVar_STRUTIL
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            If mVar_DirtySTRPROG Then
                Try
                    DataSource.Fields("STRPROG") = mVar_STRPROG
                Catch e As Exception
                    msgErr = msgErr & e.Message
                End Try
            End If

            Return msgErr
        End Function

        ''[------------------------------------------------------------------------]'
        Public Sub ClearDirty()
            mVar_DirtySTRCOD = False
            mVar_DirtySTORE = False
            mVar_DirtySTRDESC = False
            mVar_DirtySTRTYPE = False
            mVar_DirtySTRADDR = False
            mVar_DirtySTRCITY = False
            mVar_DirtySTRDEPT = False
            mVar_DirtySTRSITE = False
            mVar_DirtySTRNOTE = False
            mVar_DirtySTRDCRE = False
            mVar_DirtySTRDMAJ = False
            mVar_DirtySTRUTIL = False
            mVar_DirtySTRPROG = False
        End Sub
        ''[------------------------------------------------------------------------]'
        Public Sub SetDirty()
            mVar_DirtySTRCOD = True
            mVar_DirtySTORE = True
            mVar_DirtySTRDESC = True
            mVar_DirtySTRTYPE = True
            mVar_DirtySTRADDR = True
            mVar_DirtySTRCITY = True
            mVar_DirtySTRDEPT = True
            mVar_DirtySTRSITE = True
            mVar_DirtySTRNOTE = True
            mVar_DirtySTRDCRE = True
            mVar_DirtySTRDMAJ = True
            mVar_DirtySTRUTIL = True
            mVar_DirtySTRPROG = True
        End Sub

    End Class
End Namespace